package com.wtwd.device.service.impl;


import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wtwd.device.dao.LocationDataMapper;
import com.wtwd.device.model.entity.LocationData;
import com.wtwd.device.model.vo.LocationDataVo;
import com.wtwd.device.service.ILocationDataService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author mjy
 * @since 2024-05-21
 */
@Service
public class LocationDataServiceImpl extends ServiceImpl<LocationDataMapper, LocationData> implements ILocationDataService {

    @Resource
    private LocationDataMapper locationDataMapper;

    @Override
    public List<LocationData> getDeviceLocationByTime(Long deviceId, String startTime, String endTime) {
        return new LambdaQueryChainWrapper<>(locationDataMapper)
                .eq(LocationData::getDeviceId, deviceId)
                .between(LocationData::getLocationTime, startTime, endTime)
                .list();
    }

    @Override
    public LocationDataVo getNewDeviceLocationByTime(Long deviceId,String time) {
        return locationDataMapper.getNewDeviceLocationByTime(deviceId,time);
    }
}
